package com.dy.nygl.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.dy.nygl.mapper.EnergyYearMapper;
import com.dy.nygl.pojo.EnergyYear;
import com.dy.nygl.service.EnergyYearService;

@Service("energyYearService")
public class EnergyYearServiceImpl implements EnergyYearService {

	@Resource(name = "energyYearDao")
	private EnergyYearMapper energyYearDao;

	@Override
	public void insert(EnergyYear energyYear) {
		EnergyYear energyYear2 = new EnergyYear();
		energyYear2.setId(energyYear.getId());
		energyYear2.setName(energyYear.getName());
		energyYearDao.insertSelective(energyYear2);
	}

	@Override
	public void update(EnergyYear energyYear) {
		
		System.err.println("---------------Id--"+energyYear.toString());
		EnergyYear energyYear2 = new EnergyYear();
		energyYear2.setId(energyYear.getId());
		energyYear2.setName(energyYear.getName());
		energyYear2.setJan(energyYear.getJan());
		energyYear2.setFeb(energyYear.getFeb());
		energyYear2.setMar(energyYear.getMar());
		energyYear2.setApr(energyYear.getApr());
		energyYear2.setMay(energyYear.getMay());
		energyYear2.setJun(energyYear.getJun());
		energyYear2.setJuly(energyYear.getJuly());
		energyYear2.setAug(energyYear.getAug());
		energyYear2.setSep(energyYear.getSep());
		energyYear2.setOct(energyYear.getOct());
		energyYear2.setNov(energyYear.getNov());
		energyYear2.setDec1(energyYear.getDec1());
		energyYear2.setYear(energyYear.getYear());

		energyYearDao.updateByPrimaryKeySelective(energyYear2);

	}

	@Override
	public List<EnergyYear> selectAll() {

		List<EnergyYear> list = energyYearDao.selectAll();
		return list;
	}

	@Override
	public EnergyYear selectById(Integer id) {
		EnergyYear energyYear=energyYearDao.selectByPrimaryKey(id);
		return energyYear;
	}

	@Override
	public List<EnergyYear> selectPeriods(Integer beginId, Integer endId) {
		List<EnergyYear> list=energyYearDao.selectPeriods(beginId, endId);
		return list;
	}
}
